<template>
  <el-card style="margin-bottom:20px;">
    <div slot="header" class="clearfix">
      <span>关于我</span>
    </div>

    <div class="user-profile">
      <div class="box-center">
        <pan-thumb :image="user.avatar" :height="'100px'" :width="'100px'" :hoverable="false">
          <div>你好</div>
          {{ user.role }}
        </pan-thumb>
      </div>
      <div class="box-center">
        <div class="user-name text-center"> {{ this.user.name }} </div>
      </div>
    </div>

    <div class="user-bio">
      <div class="user-education user-bio-section">
        <div class="user-bio-section-header"><svg-icon icon-class="education" /><span>个人介绍</span></div>
        <div class="user-bio-section-body">
          <div class="text-muted">
            西安交通大学软件工程
          </div>
        </div>
      </div>

      <div class="user-skills user-bio-section">
        <div class="user-bio-section-header"><svg-icon icon-class="skill" /><span>最近来访(9)</span></div>
        <div class="user-myspace-base-person-visit-record-body">
          <div class="user-myspace-base-person-visit-record-body-items" title="1小时前" data-user-id="159907">
            <div class="user-myspace-base-person-visit-record-body-items-photo">
              <img class="img-responsive" src="https://cdn.acwing.com/media/user/profile/photo/159907_md_0bd65c90c4.jpg" alt="用户头像">
            </div>
            <div class="user-myspace-base-person-visit-record-body-items-username">
              wkingyu
            </div>
          </div>
          <div class="user-myspace-base-person-visit-record-body-items" title="19天前" data-user-id="442032">
            <div class="user-myspace-base-person-visit-record-body-items-photo">
              <img class="img-responsive" src="https://cdn.acwing.com/media/user/profile/photo/442032_md_ecf0e2c8fb.jpg" alt="用户头像">
            </div>
            <div class="user-myspace-base-person-visit-record-body-items-username">
              华_00
            </div>
          </div>
          <div class="user-myspace-base-person-visit-record-body-items" title="29天前" data-user-id="96356">
            <div class="user-myspace-base-person-visit-record-body-items-photo">
              <img class="img-responsive" src="https://cdn.acwing.com/media/user/profile/photo/96356_md_30e2a9f1af.jpg" alt="用户头像">
            </div>
            <div class="user-myspace-base-person-visit-record-body-items-username">
              asdaso
            </div>
          </div>
          <div class="user-myspace-base-person-visit-record-body-items" title="2023-03-13 19:48" data-user-id="29884">
            <div class="user-myspace-base-person-visit-record-body-items-photo">
              <img class="img-responsive" src="https://cdn.acwing.com/media/user/profile/photo/29884_md_cfa2bb6368.jpg" alt="用户头像">
            </div>
            <div class="user-myspace-base-person-visit-record-body-items-username">
              notion
            </div>
          </div>
          <div class="user-myspace-base-person-visit-record-body-items" title="2023-01-19 18:52" data-user-id="239406">
            <div class="user-myspace-base-person-visit-record-body-items-photo">
              <img class="img-responsive" src="https://cdn.acwing.com/media/user/profile/photo/239406_md_e094dee950.jpg" alt="用户头像">
            </div>
            <div class="user-myspace-base-person-visit-record-body-items-username">
              Aurora_29
            </div>
          </div>
          <div class="user-myspace-base-person-visit-record-body-items" title="2023-01-17 22:05" data-user-id="228930">
            <div class="user-myspace-base-person-visit-record-body-items-photo">
              <img class="img-responsive" src="https://cdn.acwing.com/media/user/profile/photo/228930_md_975ef66387.png" alt="用户头像">
            </div>
            <div class="user-myspace-base-person-visit-record-body-items-username">
              sweet.
            </div>
          </div>
          <div class="user-myspace-base-person-visit-record-body-items" title="2023-01-17 21:54" data-user-id="257218">
            <div class="user-myspace-base-person-visit-record-body-items-photo">
              <img class="img-responsive" src="https://cdn.acwing.com/media/user/profile/photo/257218_md_83c88f6087.jpg" alt="用户头像">
            </div>
            <div class="user-myspace-base-person-visit-record-body-items-username">
              aayc
            </div>
          </div>
          <div class="user-myspace-base-person-visit-record-body-items" title="2023-01-17 21:54" data-user-id="254457">
            <div class="user-myspace-base-person-visit-record-body-items-photo">
              <img class="img-responsive" src="https://cdn.acwing.com/media/user/profile/photo/254457_md_007cd988ca.jpg" alt="用户头像">
            </div>
            <div class="user-myspace-base-person-visit-record-body-items-username">
              Sponge
            </div>
          </div>
          <div class="user-myspace-base-person-visit-record-body-items" title="2023-05-04 21:56" data-user-id="140770">
            <div class="user-myspace-base-person-visit-record-body-items-photo">
              <img class="img-responsive" src="https://cdn.acwing.com/media/user/profile/photo/140770_md_7e0d57dd59.jpg" alt="用户头像">
            </div>
            <div class="user-myspace-base-person-visit-record-body-items-username">
              rzybzzzz
            </div>
          </div>
        </div>
      </div>
    </div>
  </el-card>
</template>

<script>
import PanThumb from '@/components/PanThumb'
import state from '../../../store/modules/user'
export default {
  components: { PanThumb },
  props: {
    user: {
      type: Object,
      default: () => {
        return {
          name: '',
          email: '',
          avatar: '',
          role: ''
        }
      }
    }
  },
  created() {
    this.getUser()
  },
  methods: {
    getUser() {
      this.user = {
        name: state.state.name,
        role: this.roles.join(' | '),
        email: 'admin@test.com',
        avatar: this.avatar
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.user-myspace-base-person-visit-record-body {
  display: flex; /* 使用 Flexbox 布局 */
  flex-wrap: wrap; /* 允许换行，以便在小屏幕上显示 */
}

.user-myspace-base-person-visit-record-body-items {
  flex: 0 0 25%; /* 每行显示四个用户头像，可根据需要调整 */
  padding: 2%; /* 可选：设置每个项的内边距 */
  box-sizing: border-box; /* 让内边距不增加元素宽度 */
}

.user-myspace-base-person-visit-record-body-items-photo {
  text-align: center; /* 图片居中显示 */
}

.user-myspace-base-person-visit-record-body-items-photo img {
  max-width: 100%; /* 图片宽度最大为父容器宽度 */
  height: auto; /* 图片高度自适应 */
}

.user-myspace-base-person-visit-record-body-items-username {
  text-align: center; /* 用户名居中显示 */
}

.box-center {
  margin: 0 auto;
  display: table;
}

.text-muted {
  color: #777;
}

.user-profile {
  .user-name {
    font-weight: bold;
  }

  .box-center {
    padding-top: 10px;
  }

  .user-role {
    padding-top: 10px;
    font-weight: 400;
    font-size: 14px;
  }

  .box-social {
    padding-top: 30px;

    .el-table {
      border-top: 1px solid #dfe6ec;
    }
  }

  .user-follow {
    padding-top: 20px;
  }
}

.user-bio {
  margin-top: 20px;
  color: #606266;

  span {
    padding-left: 4px;
  }

  .user-bio-section {
    font-size: 14px;
    padding: 15px 0;

    .user-bio-section-header {
      border-bottom: 1px solid #dfe6ec;
      padding-bottom: 10px;
      margin-bottom: 10px;
      font-weight: bold;
    }
  }
}
</style>
